import axios from 'axios';
import { commonParams } from '@/common/js/config';
import api from './apiUrl';

export function getTopList() {
  const url = api.topList;
  const data = Object.assign({}, commonParams, {
    uin: 0,
    needNewCode: 1,
    platform: 'h5',
    format: 'json',
  });
  return axios.get(url, {
    params: data,
  }).then((res) => {
    return Promise.resolve(res.data);
  });
}

export function getMusicList(topid) {
  const url = api.topListSongs;
  const data = Object.assign({}, commonParams, {
    topid,
    tpl: 3,
    uin: 0,
    needNewCode: 1,
    platform: 'h5',
    page: 'detail',
    type: 'top',
    format: 'json',
  });
  return axios.get(url, {
    params: data,
  }).then((res) => {
    return Promise.resolve(res.data);
  });
}
